//
//  CLTabPagerView.h
//  Charles
//
//  Created by Leo on 2019/5/20.
//  Copyright © 2019 charles. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "CLPagerView.h"
#import "CLTabPagerBar.h"

NS_ASSUME_NONNULL_BEGIN
@class CLTabPagerView;
@protocol CLTabPagerViewDataSource <NSObject>

- (NSInteger)numberOfViewsInTabPagerView;

- (UIView *)tabPagerView:(CLTabPagerView *)tabPagerView viewForIndex:(NSInteger)index prefetching:(BOOL)prefetching;

- (NSString *)tabPagerView:(CLTabPagerView *)tabPagerView titleForIndex:(NSInteger)index;

@end


@protocol CLTabPagerViewDelegate <NSObject>
@optional

- (void)tabPagerView:(CLTabPagerView *)tabPagerView willDisplayCell:(UICollectionViewCell<CLTabPagerBarCellProtocol> *)cell atIndex:(NSInteger)index;
- (void)tabPagerView:(CLTabPagerView *)tabPagerView didSelectTabBarItemAtIndex:(NSInteger)index;

- (void)tabPagerView:(CLTabPagerView *)tabPagerView willAppearView:(UIView *)view forIndex:(NSInteger)index;
- (void)tabPagerView:(CLTabPagerView *)tabPagerView didDisappearView:(UIView *)view forIndex:(NSInteger)index;

- (void)tabPagerViewWillBeginScrolling:(CLTabPagerView *)tabPagerView animate:(BOOL)animate;
- (void)tabPagerViewDidEndScrolling:(CLTabPagerView *)tabPagerView animate:(BOOL)animate;

@end

@interface CLTabPagerView : UIView

@property (nonatomic, weak, readonly) CLTabPagerBar *tabBar;
@property (nonatomic, weak, readonly) CLPagerView *pageView;
@property (nonatomic, strong, readonly) CLPagerViewLayout<UIView *> *layout;

@property (nonatomic, weak, nullable) id<CLTabPagerViewDataSource> dataSource;
@property (nonatomic, weak, nullable) id<CLTabPagerViewDelegate> delegate;

@property (nonatomic, assign) CGFloat tabBarHeight;

- (void)registerClass:(Class)Class forTabBarCellWithReuseIdentifier:(NSString *)identifier;
- (void)registerNib:(UINib *)nib forTabBarCellWithReuseIdentifier:(NSString *)identifier;

- (void)registerClass:(Class)Class forPagerCellWithReuseIdentifier:(NSString *)identifier;
- (void)registerNib:(UINib *)nib forPagerCellWithReuseIdentifier:(NSString *)identifier;
- (UIView *)dequeueReusablePagerCellWithReuseIdentifier:(NSString *)identifier forIndex:(NSInteger)index;

- (void)scrollToViewAtIndex:(NSInteger)index animate:(BOOL)animate;
- (void)updateData;
- (void)reloadData;

@end

NS_ASSUME_NONNULL_END
